<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 数组排序 </title>
</head>
<body>
<h2>自制 Min / Max JavaScript 方法</h2>
<p>此函数遍历数组，用找到的最高值与每个值进行比较：</p>

<p>最高值是：<span id="demo"></span></p>

<script>
  var points = [40, 100, 1, 5, 25, 10];
  document.getElementById("demo").innerHTML = myArrayMax(points);

  function myArrayMax(arr) {
    var len = arr.length;
    var max = -Infinity;
    while (len--) {
      if (arr[len] > max) {
        max = arr[len];
      }
    }
    return max;
  }
</script>
</body>
</html>